package com.lixin.smartclassroom.ui.home.tab1.activity

import com.drake.brv.utils.bindingAdapter
import com.drake.net.utils.scopeNetLife
import com.lixin.smartclassroom.api.getclasscoursemessage
import com.lixin.smartclassroom.bean.DataListBean
import com.lixin.smartclassroom.databinding.FragmentRecyclerCustomBinding
import com.lixin.smartclassroom.ui.home.adapter.taskMessage
import com.lixinkeji.base.BaseActivity
import com.lixinkeji.extension.getIntentString
import com.lixinkeji.extension.gone
import com.lixinkeji.extension.visible

/**
 * Description 任务通知
 * Author: lwc
 * Date:2023/12/7 16:13
 */
class TaskMessageAct : BaseActivity<FragmentRecyclerCustomBinding>(){
    override fun getViewBinding() = FragmentRecyclerCustomBinding.inflate(layoutInflater)

    override fun topBarHide() = false
    override fun startPadding() = true
    private lateinit var listBean: ArrayList<DataListBean>

    override fun title(): String {
        taskType = getIntentString("type")
        when(taskType){
            "3"->return "智慧课堂"
            "4"->return "主题场馆"
            "5"->return "研学课程"
        }
        return super.title()
    }
    private var taskType = ""


    override fun iniView() {

        binding.recycler.taskMessage(taskType)

        binding.apply {
            refresh.onRefresh {
                scopeNetLife {
                    listBean = getclasscoursemessage(index,10,taskType)!!
                    addData(listBean) {
                        if (binding.recycler.bindingAdapter.models?.size == 0) {
                            binding.state.showEmpty()
                            binding.recycler.gone()
                        } else {
                            binding.recycler.visible()
                        }
                        listBean.size == 10
                    }
                }
            }.autoRefresh()
        }
    }
}